package com.example.news;

import com.example.news.slice.DetailAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.components.webengine.ResourceRequest;
import ohos.agp.components.webengine.WebAgent;
import ohos.agp.components.webengine.WebView;

public class DetailAbility extends Ability {
    private WebView webView;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_detail);
        initView();
        String url = intent.getStringParam("news");
        webView.load(url);
        webView.setWebAgent(new WebAgent() {
            @Override
            public boolean isNeedLoadUrl(WebView webView, ResourceRequest request) {
                return super.isNeedLoadUrl(webView, request);
            }
        });
        webView.getWebConfig().setJavaScriptPermit(true);
    }

    private void initView() {
        webView = findComponentById(ResourceTable.Id_webview);
    }


}
